package org.winexpress

/**
 *
 * @author Swee Zhi
 */
class Product {
    int id

    String productName
    String description
    String imageUrl
//    int productTypeId // just a reference to ProductType Table
    String size
    double costPrice
    double sellingPrice  
    int stockCount

    static hasOne = [productType:ProductType]
    static hasMany = [productOptions:ProductOption, ratingComments:RatingComment, invoiceItem:InvoiceItem, cartItem:CartItem]
 
    static mapping = {
        description type: 'text'
        productOptions cascade: "all-delete-orphan"
    }
    
    static constraints = {
        id(blank:false, unique:true)
        productName(blank:false, unique:true)
        description(blank:false)
        imageUrl(blank:false)
        productType(blank:false)
        size(blank:false)
        costPrice(blank:false)
        sellingPrice(blank:false)
        stockCount(blank:false)
    }
}

